home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8893 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: fims-ara1.massey.ac.nz!user
  2. From: N.Perry@massey.ac.nz (Nigel Perry)
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: on OO differnces between Ada95 and C++
  5. Date: Tue, 27 Feb 1996 20:52:33 +1200
  6. Organization: Dept of Computer Science, Massey University
  7. Message-ID: <N.Perry-2702962052330001@fims-ara1.massey.ac.nz>
  8. References: <4gbq7q$g08@qualcomm.com> <3129F185.41C6@Rational.COM> <4gi413$qo1@druid.borland.com> <4gspen$ot0@hacgate2.hac.com> <4gt3ag$76m@druid.borland.com>
  9. NNTP-Posting-Host: fims-ara1.massey.ac.nz
  10.  
  11. In article <4gt3ag$76m@druid.borland.com>, pete@borland.com (Pete Becker) wrote:
  12.  
  13. <snip>
  14. >No, my original statement is correct: a program which contains multiple 
  15. >definitions of the same class is not a valid C++ program because it violates 
  16. >the one definition rule. That is exactly the case that the original message 
  17. <snip>
  18. >so cavalierly. There aren't many compilers that enforce this rule, but it is 
  19. >nevertheless a constraint on valid C++ programs.
  20.  
  21. C++ Draft Standard: 3.2 One defintion rule, clause 8:
  22.  
  23. No diagnostic is required for a violation of the ODR rule.
  24.  
  25. Similarly, 3.5 Program and linkage, clause 9 ends:
  26.  
  27. A violation of this rule on type identity does not require a diagnostic
  28.  
  29. [also many other places in the Standard]
  30.  
  31. What does this mean. Well Pete may be right (I haven't checked) that the
  32. code is "wrong", but "wrong" code does not require a diagnostic in C++.
  33. The opposite of a diagnostic is surely a succesful compile & link (but not
  34. necessarily a succesful execution!), so "wrong" code meets the Standard...
  35. My guess is that defining "private" as "public" to break encapsulation
  36. isn't forbidden by the Standard - if it was then it wouldn't be C/C++
  37. would it? :-)
  38.  
  39. Don't people use C/C++ so they *can* break the rules? If you want strict type
  40. checking etc. go use Ada 95, Haskell, SML, etc. etc. etc.
  41.  
  42. Just my 2c's worth :-)
  43.  
  44. -- 
  45. Dr Nigel Perry                  Email: N.Perry@massey.ac.nz
  46. Department of Computer Science  Tel:   +64 6 350 4007
  47. Massey University               Fax:   +64 6 350 5611 Attn. Dr N. Perry
  48. Palmerston North                Ftp/Gopher: smis-asterix.massey.ac.nz
  49. New Zealand                        (Mac software/Research papers)
  50.  
  51. The Cycle Helmet Law: New Zealand's Shame, Speeding before children :-(
  52.                       Prevention is better than padding!
  53.